<!--
 * @Description: 复制文章页弹窗
 * @Autor: starzhou
 * @Date: 2020-09-02 11:58:29
 * @LastEditTime: 2020-09-09 15:48:26
-->
<style scoped>
* {
  margin: 0 0;
  padding: 0 0;
}
ul li {
  list-style: none;
}
.modalDetail {
  display: flex;
}
.layer {
  width: 100%;
  height: 100%;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 999;
}
.warnUserList {
  background: #fff;
  width: 660px;
  height: 600px;
  position: fixed;
  left: 50%;
  margin-left: -228px;
  top: 40%;
  margin-top: -175px;
  z-index: 9999;
  border: 1px solid #ccd5f2;
  box-shadow: 0 0 10px 1px #e5e5e5;
}
.nav-list-zzr {
  width: 218px;
  display: flex;
  height: 36px;
  justify-content: space-around;
  margin: 10px auto 10px 20px;
  margin-bottom: 5px;
  border-bottom: 1px solid #d9d9d9;
}
.nav-list-zzr li {
  height: 36px !important;
  line-height: 36px;
  margin: 0 !important;
}
.nav-list-zzr .checkLi {
  color: #ff880c !important;
}
.canWarn-list {
  height: 410px;
  overflow-x: hidden;
  border: 1px solid #e4e4e4;
  margin-left: 20px;
  overflow-y: auto;
}
.warnUserList .checkbox {
  cursor: pointer;
  text-align: left;
  display: inline-block;
  color: #666;
  width: 100%;
  margin-left: 10px;
}
.warnUserList .checkbox:hover span {
  color: #2277da;
}
.warnUserList .simulation {
  width: 15px;
  height: 15px;
  background: url("../../assets/images/check.png") no-repeat center center;
  display: inline-block;
  vertical-align: middle;
  margin: 2px 20px 0 0;
  float: right;
}
.warnUserList .simulation2 {
  background: url("../../assets/images/checked.png") no-repeat center center;
}
.warnUserList .checkbox .warnCheckBox {
  display: block;
  width: 15px;
  height: 15px;
  cursor: pointer;
  position: absolute;
  z-index: 3;
  visibility: hidden;
  border: none;
  right: 20px;
  top: 12px;
}
.canWarn-list .checkbox span {
  float: left;
  display: inline-block;
  width: auto;
  margin: 0 0 0 20px;
  max-width: 170px;
  text-overflow: ellipsis;
  overflow: hidden;
  word-break: keep-all;
}
.warnUserList li {
  margin: 10px 0 0 0;
}
.warnList-title {
  width: 218px;
  text-align: center;
  margin: 10px auto 0 auto;
  font-weight: 600;
  color: #666;
}
.yujinglist-button {
  text-align: center;
  margin-top: 6px;
}
.yujinglist-button input {
  border: none;
  color: #333;
  background: #ddd;
  width: 52px;
  height: 26px;
  line-height: 26px;
  display: inline-block;
  cursor: pointer;
  transition: all ease 0.3s;
  border-radius: 3px;
}
.yujinglist-button input:hover {
  background: #cfcfcf;
}
.yujinglist-button .btn-warn-submit {
  margin: 0 15px 0 20px;
  background: #2277da;
  color: #fff;
}
.yujinglist-button .btn-warn-submit:hover {
  background: #1d6ac1;
}
/* 专题监测信息列表页预警弹窗样式 */
.warnUserList .modalTitle {
  display: flex;
  height: 40px;
  justify-content: space-between;
  border-bottom: 1px solid #e4e4e4;
}
.warnUserList .modalTitle p {
  display: inline-block;
  height: 40px;
  line-height: 40px;
  font-size: 18px;
  font-weight: 600;
  margin-left: 20px;
}
.warnUserList .modalTitle p:last-child {
  margin-right: 20px;
  cursor: pointer;
}
.warnUserList .modalDetail {
  display: flex;
}
.warnUserList .modalDetail .modalLeft .warnList-title {
  width: 218px;
  text-align: left;
  margin: 10px auto 10px 20px;
  font-size: 18px;
  font-weight: 600;
  color: #34383e;
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox {
  cursor: pointer;
  text-align: left;
  display: inline-block;
  color: #666;
  width: 100%;
  margin-left: 10px;
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox .simulation {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: middle;
  /* margin: 0 20px 0 0; */
  /* float: right; */
}
.warnUserList .modalDetail .modalLeft .canWarn-list li .checkbox span {
  /* float: left; */
  display: inline-block;
  width: auto;
  /* margin: 0 0 0 20px; */
  max-width: 170px;
  text-overflow: ellipsis;
  vertical-align: middle;
  overflow: hidden;
  word-break: keep-all;
}
.warnUserList .modalDetail .modalRight .fzxx-list {
  width: 95%;
  text-align: left;
  margin: 0 0 0 20px;
}
.warnUserList .modalDetail .modalRight .fzxx-list li .ffxx-left {
  color: #333;
  text-align: left;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  display: block;
}
.warnUserList .modalDetail .modalRight .fzxx-list li .ffxx-right textarea {
  overflow-x: hidden;
  border: 1px solid #ccd5f2;
  width: 360px;
  height: 360px;
  resize: none;
  padding: 10px;
}
.warnUserList .yujinglist-button {
  text-align: center;
  height: 40px;
  line-height: 40px;
  margin-top: 10px;
}
.fzxx-list li .ffxx-right input {
  width: 258px;
  height: 28px;
  line-height: 28px;
  border: 1px solid #ccd5f2;
  padding: 0 10px;
}
</style>
<template>
  <div v-if="isShow">
    <div class="layer" @click="hideProps"></div>
    <div class="warnUserList">
      <div class="modalTitle">
        <p>预警</p>
        <p class="closeModal" @click="hideProps">
          <i class="el-icon-close"></i>
        </p>
      </div>
      <div class="modalDetail">
        <div class="modalLeft">
          <div class="warnList-title">选择预警对象</div>
          <ul class="nav-list-zzr">
            <li :class="[warnList.warnType == 1 ? 'checkLi' : '']" @click="handleType(1)">微信公众号</li>
            <li :class="[warnList.warnType == 2 ? 'checkLi' : '']" @click="handleType(2)">邮件</li>
          </ul>
          <ul class="canWarn-list">
            <li @click="handleOptions(item)" v-for="(item, index) in objList" :key="index">
              <label class="checkbox">
                <div
                  :class="['simulation', warnList.userIdList.includes(item.id) ? 'simulation2' : '']"
                ></div>
                <span>{{item.userName}}</span>
              </label>
            </li>
          </ul>
        </div>
        <div class="modalRight">
          <ul class="fzxx-list">
            <li>
              <div class="ffxx-left">标题：</div>
              <div class="ffxx-right">
                <input
                  placeholder="输入标题文字"
                  type="text"
                  style="width: 360px;"
                  v-model="warnList.title"
                />
              </div>
            </li>
            <li>
              <div class="ffxx-left">摘要：</div>
              <div class="ffxx-right">
                <textarea v-model="alertContent"></textarea>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="yujinglist-button">
        <input type="button" value="确定" class="queding btn-warn-submit" @click="subInfo" />
        <input type="button" value="取消" class="quxiao btn-cancle" @click="hideProps" />
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "sent-alert",
  props: {
    isShow: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      objList: [],
      warnList: {
        warnType: 1,
        userIdList: [],
        title: "",
        content: "",
      },
    };
  },
  computed: {
    alertContent() {
      return this.warnList.content || this.warnList.summary;
    }
  },
  watch: {
    isShow() {
      if (!this.isShow) {
        this.objList = [];
        this.warnList = {
          warnType: 1,
          userIdList: [],
          title: "",
          content: "",
        };
      }
    },
  },
  methods: {
    handleOptions(item) {
      if (this.warnList.userIdList.includes(item.id)) {
        let arr = this.warnList.userIdList.filter((itm) => itm != item.id);
        this.$set(this.warnList, "userIdList", arr);
      } else {
        this.warnList.userIdList.push(item.id);
      }
    },
    hideProps() {
      this.$emit("update:isShow", false);
    },
    handleType(type) {
      this.$set(this.warnList, "warnType", type);
    },
    subInfo() {
      let { userIdList } = this.warnList;
      if (userIdList.length == 0) {
        this.$message("请先选择发送对象");
        return;
      }
      this.$emit("sendWarnMessage", this.warnList);
    },
  },
};
</script>